package com.ruoyi.camp.api;

import com.ruoyi.camp.domain.Camp;
import com.ruoyi.camp.domain.Collect;
import com.ruoyi.camp.service.ICollectService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 收藏Controller
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@RestController
@RequestMapping("/wechat/collect")
public class WxCollectController extends BaseController
{
    @Autowired
    private ICollectService collectService;

    /**
     * 查询收藏列表
     */
    @GetMapping("/list")
    public AjaxResult list()
    {
        String userId = SecurityUtils.getLoginUser().getUser().getNickName();
        List<Camp> list = collectService.selectCollectListByUserId(userId);
        return success(list);
    }
    /**
     * 新增收藏
     */
    @PostMapping
    public AjaxResult collect(@RequestBody Collect collect)
    {
        System.out.println("collect:"+collect);
        return success(collectService.collect(collect));
    }
}
